<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
	<title>配送企业区域管理</title>
	<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
	 <!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>配送企业区域设置</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">交易</a></li>
            <li class="active"><a href="#">配送关系</a></li>
            <li class="active"><a href="#">配送企业区域设置</a></li>
        </ol>
    </section>
    
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
                <div class="input">
            	
            	<div class="textalign">配送企业：</div>
                <div class="boxinput">
                     <input class="textinput"  id="compName" name="compName" type="text" placeholder="配送企业" />
                </div>
                <div class="textalign">地区：</div>
                <div class="boxinput">
                     <input class="textinput"  id="areaName" name="areaName" type="text" placeholder="地区" />
                </div>
                 <div class="textalign">
                  		<button type="button"  onclick="gridSerch()"  class="btn btn-success btn-sm" id="selectc">查&nbsp;询</button>
                  </div>
            </div>
            
            </div>
        </div>
         
        <table class="jqgrid" id="gridlist"></table>
        <div id="prowed2"></div>
            
            <div class=" box box-warning bottongroup" id="bottongroup">
			<label onclick="window.location.href='${ctx}/baseDelAreaRel/toAddDelAreaRel.html'" class="btn btn-primary btn-sm">新 增</label>
			<label onclick="deleteDelArea()" class="btn btn-primary btn-sm">删 除</label>
		</div>
</section>
<%@ include file="/WEB-INF/component/commonJS.jsp"%>
<script type="text/javascript">
function deleteDelArea(){
	var rowIds = $("#gridlist").jqGrid("getGridParam", "selarrrow") || [];
    if (rowIds.length <= 0) {
    	$.HN.message.alert("请选择要删除的配送企业区域！", "提示信息", "warn");
        return;
    }
	    $.HN.message.confirm('确定删除配送企业区域？', '', '').on(function (e) {
        if (e) {
        	var list = [];
            for (var i=0; i<rowIds.length; i++) {
                rowId = rowIds[i];
                list.push({"delRelId":rowId});
			}
            $.post("${ctx}/baseDelAreaRel/deleteDelArea.html", {
				"array" : json.jsonToString(list)
			}, function(result) {
				if (result.success) {
					$.HN.message.alert(result.msg, "消息", "success");
					$("#gridlist").trigger("reloadGrid");
				} else {
					$.HN.message.alert(result.msg, "消息", "error");
				}
			}, "json");
        }
    });
}
	//绑定回车
	$('#compName,#areaName').bind('keydown', function(event) {
	    if (event.keyCode == "13") {        //13 位电脑上回车键的位置代码
	        $('#selectc').click();
	    }
	}); 
	

$(function () {
jQuery("#gridlist").jqGrid({
	url: "${ctx}/baseDelAreaRel/getBaseDelAreaRelListCenterData.html",
    mtype: "POST",
	datatype: "json",
	autowidth: true,
	multiselect:true,
	shrinkToFit:true,
   	colNames:['id','配送企业','地区'],
   	colModel:[
		{name:'baseDelAreaRelId',index:'baseDelAreaRelId',key:true,hidden:true},
		{name:'delCompName',index:'delCompName',align:"center", width:140,  sortable:false},
		{name:'arFullName',index:'arFullName',align:"center", width:120, sortable:false}
   	],
	 rowNum: 20,
     rowList: [10, 20, 50,100],
     rownumbers: true,
     multiselect: true,
     pager: "#prowed2",
     viewrecords: true,
     caption: "配送企业区域关系列表",
     jsonReader: {
         repeatitems: false,
         id: "ids"
     },
     gridComplete:function(){
         //序号列宽度自适应（参数为jqgridID）
         autoRNWidth("gridlist");
         //数据只有一条时默认选中（参数为jqgridID）
         selectByOneData("gridlist");
     }
});
	jQuery("#gridlist").jqGrid('navGrid',"prowed2",{edit:false,add:false,del:false});
	$("#gridlist").jqGrid("setGridHeight", create());
	$(window).trigger("resize");
});


function gridSerch() {
	var compName = $.trim($("#compName").val());
	var areaName = $.trim($("#areaName").val());
	$("#gridlist").jqGrid('setGridParam',{  
        datatype:'json',
        postData:{
        		"compName":compName,
        		"areaName":areaName
        		},
        		page :1
    }).trigger("reloadGrid"); //重新载入  
}

	
</script>
</body>
</html>